<?php 
include("db.php");
include("fileop.php");
?>

<?php

$con=mysqli_connect(DBADDR,DBUSER,DBPWD,DBNAME);
mysql_query('set names utf8'); 
// Check connection
if (mysqli_connect_errno()){
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  echo "Returning in 5 seceonds";
  header("refresh:5;url=allresto.php");
}

$selectedid = $_POST['selectedid'];
$namefr = $_POST['namefr'];
$namearb = $_POST['namearb'];
$restoredu = $_POST['restoredu'];
$restotype = $_POST['restotype'];
$restonation = $_POST['restonation'];
$tel = $_POST['tel'];
$address = $_POST['address'];
$mail = $_POST['mail'];
$descfr = $_POST['descfr'];
$descarb = $_POST['descarb'];
$opentimefr = $_POST['opentimefr'];
$opentimearb = $_POST['opentimearb'];
$hasreserv = isset($_POST['hasreserv'])? 1 : 0;
$hascoupon = isset($_POST['hascoupon'])? 1 : 0;
$intropic = isset($_FILES["intro_pic"])? addfile('intro_pic'): "";
$website= $_POST['website'];;


$sql = "UPDATE `inforesto`.`info_resto` SET 
`RESTO_TYPE_ID` = '".$restotype."',
`RESTO_NAME_FR` = '".$namefr."',
`RESTO_NAME_ARB` = '".$namearb."',
`RESTO_INTRO_ARB` = '".$descarb."',
`RESTO_INTRO_FR` = '".$descfr."',
`RESTO_WEBSITE` = '".$website."',
`RESTO_NATION` = '".$restonation."',
`RESTO_ADDR` = '".$address."',
`RESTO_MAIL` = '".$mail."',
`RESTO_TIME_FR` = '".$opentimefr."',
`RESTO_TIME_ARB` = '".$opentimearb."',
`RESTO_TEL` = '".$tel."',
`RESTO_REDU` = '".$restoredu."',
`HAS_COUPON` = ".$hascoupon.",
`HAS_RESERV` = ".$hasreserv;

if($intropic!= ""){
$sql = $sql.", `INTRO_PIC` = '".$intropic."'";
}
$sql = $sql."  WHERE `info_resto`.`RESTO_ID` =".$selectedid.";";


mysqli_query($con,$sql);

mysqli_close($con);

header("Location:allresto.php?succ=1&type=m");


?>